package com.uzai.console.web.cms;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.cms.customlink.CmsCustomLinkDto;
import com.uzai.console.dto.cms.customlink.CmsCustomLinkIdDto;
import com.uzai.console.dto.cms.customlink.CmsCustomLinkQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.cms.CmsCustomLinkService;
import com.uzai.console.vo.cms.customlink.CmsCustomLinkVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * CMS自定义链接
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "自定义链接",tags = "CMS小程序|自定义链接")
@ApiSort(7)
@RestController
public class CmsCustomLinkController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(CmsCustomLinkController.class);

    @Autowired
    private CmsCustomLinkService cmsCustomLinkService;

    @ApiOperation(value = "分页查询CMS自定义链接列表", notes = "分页查询CMS自定义链接列表", response = CmsCustomLinkVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/cmsCustomLink/findCmsCustomLinkList")
    public Object findCmsCustomLinkList(@RequestBody CmsCustomLinkQuery cmsCustomLinkQuery){
        return cmsCustomLinkService.findCmsCustomLinkList(cmsCustomLinkQuery);
    }

    @ApiOperation(value = "查询CMS自定义链接信息", notes = "查询CMS自定义链接信息", response = CmsCustomLinkVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/cmsCustomLink/findCmsCustomLink")
    public Object findCmsCustomLink(@RequestBody CmsCustomLinkIdDto cmsCustomLinkIdDto){
        return cmsCustomLinkService.findCmsCustomLink(cmsCustomLinkIdDto);
    }

    @SystemLogType(model = SystemModelEnum.CmsCustomLink, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加CMS自定义链接信息", notes = "添加CMS自定义链接信息")
    @ApiOperationSupport(order = 3)
    @PostMapping("/cmsCustomLink/addCmsCustomLink")
    public Object addCmsCustomLink(@RequestBody CmsCustomLinkDto cmsCustomLinkDto){
        cmsCustomLinkService.addCmsCustomLink(cmsCustomLinkDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.CmsCustomLink, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑CMS自定义链接信息", notes = "编辑CMS自定义链接信息")
    @ApiOperationSupport(order = 4)
    @PostMapping("/cmsCustomLink/updateCmsCustomLink")
    public Object updateCmsCustomLink(@RequestBody CmsCustomLinkDto cmsCustomLinkDto){
        cmsCustomLinkService.updateCmsCustomLink(cmsCustomLinkDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.CmsCustomLink, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除CMS自定义链接信息", notes = "删除CMS自定义链接信息")
    @ApiOperationSupport(order = 5)
    @PostMapping("/cikuKeywordReply/deleteCmsCustomLink")
    public Object deleteCmsCustomLink(@RequestBody CmsCustomLinkIdDto cikuKeywordsReplyIdDto){
        cmsCustomLinkService.deleteCmsCustomLink(cikuKeywordsReplyIdDto);
        return true;
    }


    @SystemLogType(model = SystemModelEnum.CmsCustomLink, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "复制官方自定义链接", notes = "复制官方自定义链接", response = CmsCustomLinkVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/cmsCustomLink/copyDefaultCmsCustomLink")
    public Object copyDefaultCmsCustomLink(){
        Long merId = getLoginInfo().getMerId();
        return cmsCustomLinkService.copyDefaultCmsCustomLink(merId);
    }

}
